<template>
    <div class='login-app'>
        <h1>合众易成微信推广系统</h1>
  <a-form
    id="components-form-demo-normal-login"
    :form="form"
    class="login-form"
    @submit="handleSubmit"
  >
    <a-form-item>
      <a-input
        v-decorator="[
          'userName',
          { rules: [{ required: true, message: 'Please input your username!' }] }
        ]"
        placeholder="Username"
      >
        <a-icon
          slot="prefix"
          type="user"
          style="color: rgba(0,0,0,.25)"
        />
      </a-input>
    </a-form-item>
    <a-form-item>
      <a-input
        v-decorator="[
          'password',
          { rules: [{ required: true, message: 'Please input your Password!' }] }
        ]"
        type="password"
        placeholder="Password"
      >
        <a-icon
          slot="prefix"
          type="lock"
          style="color: rgba(0,0,0,.25)"
        />
      </a-input>
    </a-form-item>
    <a-form-item>
      <a-button
        type="primary"
        html-type="submit"
        class="login-form-button"
      >
        登录
      </a-button>
    </a-form-item>
  </a-form>
  </div>
</template>

<script>

import { Message } from 'ant-design-vue'
export default {
  beforeCreate () {
    this.form = this.$form.createForm(this);
  },
  mounted(){
  },
  methods: {
    handleSubmit (e) {
        let vo = this;
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
            const dataUrl = `backstage/userAjax.do?name=${values.userName}&pwd=${values.password}`
            vo.ajax.get(dataUrl).then((res)=>{
                if(res==1){//登录成功
                    vo.$router.push({path:'/actmanage'})
                }else{
                    Message.error('用户名或密码不正确');
                }
            })
        }
      });
    },
  },
};
</script>
<style>

body{
  background: #1d2024;
}
.login-app{
    transform: translateY(50%);
}
.login-app h1{
    color: #fff;
}
#components-form-demo-normal-login.login-form {
  max-width: 300px;
  margin: 0 auto;
}
#components-form-demo-normal-login .login-form-forgot {
  float: right;
}
#components-form-demo-normal-login .login-form-button {
  width: 100%;
}
</style>